from django.shortcuts import render
from django.http import HttpResponse
from .bar import GetBar

# Create your views here.

def index(request):
    html = '''
    <h1>卫士奇同学</h1>
    <hr>
    <h2>Chipotle 数据分析</h2>
    <div align = 'center'>
        <h3>
            <a href = '1/'>每件卖多少</a><br>
            <a href = '2/'>每件卖多少钱</a><br>
        </h3>
    </div>
    <hr>
    '''
    return HttpResponse(html)

def cartogram1(request):
    bar = GetBar('D:\数据分析\代码\chipotle.csv').bar_how_many_are_sold_per_item(bar_name='每件卖多少')
    context = dict(
        myechart = bar.render_embed(),
        host = "https://pyecharts.github.io/assets/js",
        script_list = bar.get_js_dependencies()
    )
    return render(request, 'app/index.html', context)

def cartogram2(request):
    bar = GetBar('D:\数据分析\代码\chipotle.csv').bar_how_much_are_sold_per_item(bar_name='每件卖多少钱')
    context = dict(
        myechart = bar.render_embed(),
        host = "https://pyecharts.github.io/assets/js",
        script_list = bar.get_js_dependencies()
    )
    return render(request, 'app/index.html', context)

